home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 241_01 / remante.ci < prev    next >
Text File  |  1987-08-29  |  2KB  |  89 lines

  1. /*
  2. HEADER:         CUG241;
  3. TITLE:          Inference Engine for Expert System;
  4. DATE:           12/30/85;
  5. VERSION:
  6. DESCRIPTION:   "Source code for inference engine for an Expert System.";
  7. KEYWORDS:       Artificial Intelligence, expert systems, inference engine;
  8. SYSTEM:         MS-DOS or UNIX System V;
  9. FILENAME:       REMANTE.C;
  10. WARNINGS:      "User-supported, non-commercial"
  11. AUTHORS:        George Hageman; 
  12. COMPILERS:      Microsoft C V3.00 or UNIX System V Portable C Compiler;
  13. REFERENCES:     ;
  14. ENDREF
  15. */
  16.  
  17. /*****************************************************************
  18. **                                **
  19. **      Inference -- (C) Copyright 1985 George Hageman    **
  20. **                                **
  21. **        user-supported software:                **
  22. **                                **
  23. **            George Hageman                **
  24. **            P.O. Box 11234                **
  25. **            Boulder, Colorado 80302            **
  26. **                                **
  27. *****************************************************************/
  28.  
  29. /***********************************************
  30. **
  31. **    remAnte(antecedent)
  32. **
  33. **    returns the truth value of the fact to be remembered
  34. **    similar to verify except that the fact is a known antecedent
  35. **    and is not a consequent of any rule.  And therefore can be remembered
  36. **    false as well as true.
  37. **
  38. ************************************************/
  39.  
  40. #include <stdio.h>
  41. #include "expert.h"
  42. #include "inference.h"
  43.  
  44.  
  45. int    remAnte(antecedent)
  46.     int    antecedent ;
  47. {
  48. int p_value ;
  49.  
  50. switch(ruleBuff[antecedent].flag)
  51.     {
  52.     case STRING_TRUE :
  53.     case STRING_TRUE_HYP:
  54.         knownTrue[numTrue++]=ruleBuff[antecedent].string ;
  55.         return(TRUE) ;
  56.     case STRING_FALSE :
  57.         knownTrue[numTrue++]=ruleBuff[antecedent].string ;
  58.         return(FALSE) ;
  59.     default:  /* routine to run */
  60.         if(weKnow(antecedent,&p_value) == TRUE)
  61.             return(p_value) ;
  62.         if( runRoutine(antecedent) == TRUE )
  63.             {
  64.             knownTrue[numTrue++]=ruleBuff[antecedent].string ;
  65.             if((ruleBuff[antecedent].flag == ROUTINE_TRUE) ||
  66.                 (ruleBuff[antecedent].flag == ROUTINE_TRUE_HYP))
  67.                 {
  68.                 return(TRUE) ;
  69.                 }
  70.             else
  71.                 {
  72.                 return(FALSE) ;
  73.                 }
  74.             }
  75.         else
  76.             {
  77.             knownFalse[numFalse++]=ruleBuff[antecedent].string ;
  78.             if(ruleBuff[antecedent].flag == ROUTINE_FALSE)
  79.                 {
  80.                 return(TRUE) ;
  81.                 }
  82.             else
  83.                 {
  84.                 return(FALSE) ;
  85.                 }
  86.             }
  87.     }
  88. }         
  89.